//
//  Tipe_WX_View.m
//  ZITHER
//
//  Created by weixin on 2019/5/13.
//  Copyright © 2019 weixn. All rights reserved.
//

#import "Tipe_WX_View.h"
#import "Tipe_WX_Image.h"
#import "Seach_FittrateSeting_VC_WX.h"
#import "MainAntistopVC_V4.h"
#import "Ugc_Release_VC_WX_V4.h"
#import "CustomCameraVC.h"
#import "MainDiscernVC.h"

@implementation Tipe_WX_View

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
//        self.backgroundColor = [UIColor redColor];
    }
    return self;
}

-(void)setArr:(NSArray<Tipe_Model_WX *> *)arr{
    _arr = arr;
    [self funcADDTowImage];
}

-(void)funcADDTowImage{
//    Tipe_WX_Image *imageV1 = [Tipe_WX_Image initCustom:CGRectZero contentMode:2];
    Tipe_WX_Image *imageV1 = [[Tipe_WX_Image alloc]init];
    imageV1.contentMode = 2;
    [self addSubview:imageV1];
    imageV1.model = self.arr[3];
    [imageV1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(0);
        make.top.equalTo(self).offset(0);
        make.bottom.equalTo(self).offset(0);
        make.width.mas_equalTo(kScreenW/2.0-15-10);
    }];
    [[imageV1 addTag]subscribeNext:^(id  _Nullable x) {
        [self pushVC:3];
    }];
    [[imageV1.btn addTag]subscribeNext:^(id  _Nullable x) {
        [self pushVC:3];
    }];

//    Tipe_WX_Image *imageV2 = [Tipe_WX_Image initCustom:CGRectZero contentMode:2];
    Tipe_WX_Image *imageV2 = [[Tipe_WX_Image alloc]init];
    imageV2.model = self.arr[4];
    imageV2.contentMode = 2;
    [self addSubview:imageV2];

    [imageV2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(0);
        make.top.equalTo(self).offset(0);
        make.bottom.equalTo(self).offset(0);
        make.width.mas_equalTo(kScreenW/2.0-15-10);
    }];
    [[imageV2 addTag]subscribeNext:^(id  _Nullable x) {
        [self pushVC:4];
    }];
    [[imageV2.btn addTag]subscribeNext:^(id  _Nullable x) {
        [self pushVC:4];
    }];
}


-(void)pushVC:(int)j{
    if (j==0) {
        Seach_FittrateSeting_VC_WX *vc = [[Seach_FittrateSeting_VC_WX alloc]init];
        [self.getNav pushViewController:vc animated:YES];
    }else if (j==1){
        MainAntistopVC_V4 *vc = [[MainAntistopVC_V4 alloc] init];
        [self.getNav pushViewController:vc animated:YES];
    }else if (j==2){
        if (kUSER_INFO_MANAGER.userIsLogin) {
            [[serviceDefualt loadTopicDefaultSubjecte:nil]subscribeNext:^(ResponseData* x) {
                if (x.success) {
                    Ugc_Release_VC_WX_V4 *vc = [[Ugc_Release_VC_WX_V4 alloc]init];
                    vc.id = x.responseRawData[@"data"][@"id"];
                    vc.Topictitle = x.responseRawData[@"data"][@"title"];
                    [self.getNav pushViewController:vc animated:YES];
                }else{
                    [Tools showTips:x.errorInfo];
                }
            }];
        }else{
            [Tools pushSinge];
        }
    }else if (j==3){
        CustomCameraVC *vc = [[CustomCameraVC alloc] init];
        [self.getNav pushViewController:vc animated:YES];
    }else{
        if (kUSER_INFO_MANAGER.userIsLogin) {
            MainDiscernVC *vc = [[MainDiscernVC alloc]init];
            [self.getNav pushViewController:vc animated:YES];
            return ;
        }else{
            [Tools pushSinge];
        }
    }
    
}

@end
